package com.ts.webapplication.service;

import com.ts.webapplication.entity.User;
import com.ts.webapplication.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * @author tiansong
 * @create 2019/6/1/001 - {TIME}
 */
@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public ArrayList<User> findAll(){
        return userMapper.findAll();
    }

    public User find(User user){
        return userMapper.find(user);
    }

    public void delete(User user){
        userMapper.delete(user);
    }

    public void update(User user){
        userMapper.update(user);
    }

    public void addUser(User user){
        userMapper.add(user);
    }

    public ArrayList<String> findLikeName(String name){
        ArrayList<String> names = userMapper.findUserByLikeName("%" + name + "%");
        return names;
    }

    public ArrayList<User> findByName(User user){
        return userMapper.findUserByName(user);
    }
}
